unit uForm_selectdirshellview;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ToolWin, ComCtrls, StdCtrls, Grids, Outline, DirOutln,
  ShellCtrls;

type
  Tform_dialog_selectdir_shell = class(TForm)
    tv1: TShellTreeView;
    btn_ok: TButton;
    btn_cancel: TButton;
    procedure tv1Enter(Sender: TObject);
    procedure tv1Change(Sender: TObject; Node: TTreeNode);
    procedure FormShow(Sender: TObject);
    procedure btn_cancelClick(Sender: TObject);
    procedure btn_okClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
     m_result  :AnsiString;
  end;

var
  form_dialog_selectdir_shell: Tform_dialog_selectdir_shell = nil;

implementation

{$R *.dfm}

procedure Tform_dialog_selectdir_shell.tv1Enter(Sender: TObject);
begin
   //
end;

procedure Tform_dialog_selectdir_shell.tv1Change(Sender: TObject; Node: TTreeNode);
  var

    shf :TShellFolder;
    nlen :integer;
    ac :AnsiChar;
begin

  shf :=TShellFolder( Node.data );
  if shf.IsFolder = False then Exit;

  m_result := shf.PathName;

  nlen := Length(m_result);
  ac := m_result[nlen-1];
  if ac <> '\' then m_result := m_result + '\';


end;

procedure Tform_dialog_selectdir_shell.FormShow(Sender: TObject);
begin
  m_result := '';
end;

procedure Tform_dialog_selectdir_shell.btn_cancelClick(Sender: TObject);
begin
   m_result := '';
   Close();
end;

procedure Tform_dialog_selectdir_shell.btn_okClick(Sender: TObject);
begin
  Close();
end;

end.
